/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Principal.java
 *
 * Created on 08/03/2011, 09:06:07
 */

package sisgraf.view;

import java.math.BigDecimal;
import sisgraf.controler.ServicoItemOrcamentoControler;
import sisgraf.model.Material;
import sisgraf.model.ServicoItemOrcamento;
import sisgraf.view.Menu;

/**
 *
 * @author jordan
 */
public class ServicoItemOrcamentos extends javax.swing.JDialog {
    private int opcao=0;
    private boolean incluiu=false;
    private boolean alterou=false;
    private ServicoItemOrcamentoControler servicoItemOrcamentoControler;
    private ServicoItemOrcamento servicoItemOrcamento;
    private Material material;
    
    /** Creates new form Principal */
        public ServicoItemOrcamentos(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    public void setOpcao(int opcao)
    {
        this.opcao = opcao;
        formComponentResized(null);
        setLocationRelativeTo(null);

        if (servicoItemOrcamento.getItemOrcamento().getId()==null)
            jTxFdidOrcamento.setText("");
        else
            jTxFdidOrcamento.setText(servicoItemOrcamento.getItemOrcamento().getId().toString());
        jTxFdNomCli.setText(servicoItemOrcamento.getOrcamento().getCliente().getNom_cli());
        jTxFdNomVen.setText(servicoItemOrcamento.getOrcamento().getVendedor().getNom_ven());
        jTxFdDataSolicitacao.setText(servicoItemOrcamento.getOrcamento().getDataSolicitacaoForm());
        jTxFdDataEmissao.setText(servicoItemOrcamento.getOrcamento().getDataEmissaoForm());
        jTxFdDataEncerramento.setText(servicoItemOrcamento.getOrcamento().getDataEncerramentoForm());
        if (servicoItemOrcamento.getItemOrcamento().getId()==null)
            jTxFdidItemOrcamento.setText("");
        else
            jTxFdidItemOrcamento.setText(servicoItemOrcamento.getItemOrcamento().getId().toString());
        jTxFdDescricao.setText(servicoItemOrcamento.getItemOrcamento().getDescricao());
        jTxFdQuantidade.setText(servicoItemOrcamento.getItemOrcamento().getQuantidade().toString());
        jTxFdComprimento.setText(servicoItemOrcamento.getItemOrcamento().getComprimentoToString());
        jTxFdLargura.setText(servicoItemOrcamento.getItemOrcamento().getLarguraToString());
        jTxFdPrazoEntrega.setText(servicoItemOrcamento.getItemOrcamento().getPrazoEntregaForm());
        jTxFdDataAprovacao.setText(servicoItemOrcamento.getItemOrcamento().getDataAprovacaoForm());
        jTxFdDataCancelamento.setText(servicoItemOrcamento.getItemOrcamento().getDataCancelamentoForm());

        jTxFdId.setText(servicoItemOrcamento.getIdToString());
        if (servicoItemOrcamento.getMaterial()==null){
            jTxFdMaterial.setText("");
            jTxFdTipo.setText("");
            lbPorcentagemAplicacao.setEnabled(false);
            jTxFdPorcentagemAplicacao.setEnabled(false);
            lbNumeroAplicacoes.setEnabled(false);
            jTxFdNumeroAplicacoes.setEnabled(false);
        } else {
            jTxFdMaterial.setText(servicoItemOrcamento.getMaterial().getDescricao());
            jTxFdTipo.setText(servicoItemOrcamento.getMaterial().getTipo());
            jTxFdUnidade.setText(servicoItemOrcamento.getMaterial().getUnidade().getDescricao());
            material=servicoItemOrcamento.getMaterial();
            if (servicoItemOrcamento.getMaterial().getTipo().equals("aplicacao")){
                lbPorcentagemAplicacao.setEnabled(true);
                jTxFdPorcentagemAplicacao.setEnabled(true);
                lbNumeroAplicacoes.setEnabled(true);
                jTxFdNumeroAplicacoes.setEnabled(true);
                jBtCalcularQuantidade.setEnabled(true);
            } else {
                if (material.getTipo().equals("plano")){
                   jBtCalcularQuantidade.setEnabled(true);
                } else {
                   jBtCalcularQuantidade.setEnabled(false);
                }
                lbPorcentagemAplicacao.setEnabled(false);
                jTxFdPorcentagemAplicacao.setEnabled(false);
                lbNumeroAplicacoes.setEnabled(false);
                jTxFdNumeroAplicacoes.setEnabled(false);
            }
        }
        if (servicoItemOrcamento.getValorUnitario()==null){
            jTxFdCusto.setText("");
        } else {
            jTxFdCusto.setText(servicoItemOrcamento.getValorUnitarioForm());
        }
        if (servicoItemOrcamento.getPorcentagemAplicacao()==null)
            jTxFdPorcentagemAplicacao.setText("");
        else jTxFdPorcentagemAplicacao.setText(servicoItemOrcamento.getPorcentagemAplicacao().toString().replace('.', ','));
        jTxFdNumeroAplicacoes.setText(servicoItemOrcamento.getNumeroAplicacoesToString());
        if (servicoItemOrcamento.getQuantidade()==null){
            jTxFdQuantidadeMaterial.setText("");
        } else {
            jTxFdQuantidadeMaterial.setText(servicoItemOrcamento.getQuantidadeForm());
        }
        jTxFdObservacoes.setText(servicoItemOrcamento.getObservacoes());

// inicializar variaveis do servico do item do orçamento
        if (this.opcao == Menu.OP_PESQ_ALT){
            this.jLabel2.setText("Alteração de Item de Serviço do Orçamento");
        } else {
            this.jLabel2.setText("inclusão de Item de Serviço do Orçamento");
        }
        setVisible(true);
        jTxFdMaterial.setFocusable(true);
    }

    public void setServicoItemOrcamento(ServicoItemOrcamento servicoItemOrcamento){
        this.servicoItemOrcamento = servicoItemOrcamento;
    }

    public ServicoItemOrcamento getServicoItemOrcamento(){
        return this.servicoItemOrcamento;
    }

    public void setControler(ServicoItemOrcamentoControler servicoItemOrcamentoControler){
        this.servicoItemOrcamentoControler = servicoItemOrcamentoControler;
    }
    public boolean getIncluiu(){
        return this.incluiu;
    }
    public boolean getAlterou(){
        return this.alterou;
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPnlSuperior = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jPnlCentral = new javax.swing.JPanel();
        jPnlConteudo = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jTxFdidOrcamento = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTxFdNomCli = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTxFdNomVen = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jTxFdDataSolicitacao = new javax.swing.JFormattedTextField();
        jLabel9 = new javax.swing.JLabel();
        jTxFdDataEmissao = new javax.swing.JFormattedTextField();
        jLabel10 = new javax.swing.JLabel();
        jTxFdDataEncerramento = new javax.swing.JFormattedTextField();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jTxFdidItemOrcamento = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jTxFdDescricao = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jTxFdComprimento = new javax.swing.JFormattedTextField();
        jTxFdLargura = new javax.swing.JFormattedTextField();
        jTxFdQuantidade = new javax.swing.JFormattedTextField();
        jTxFdPrazoEntrega = new javax.swing.JFormattedTextField();
        jTxFdDataAprovacao = new javax.swing.JFormattedTextField();
        jTxFdDataCancelamento = new javax.swing.JFormattedTextField();
        jPanel3 = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        jTxFdId = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jTxFdMaterial = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        jTxFdTipo = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        lbPorcentagemAplicacao = new javax.swing.JLabel();
        lbNumeroAplicacoes = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTxFdObservacoes = new javax.swing.JTextArea();
        jBtPesquisaCliente = new javax.swing.JButton();
        jTxFdQuantidadeMaterial = new javax.swing.JFormattedTextField();
        jTxFdPorcentagemAplicacao = new javax.swing.JFormattedTextField();
        jTxFdNumeroAplicacoes = new javax.swing.JFormattedTextField();
        jTxFdCusto = new javax.swing.JFormattedTextField();
        jLabel23 = new javax.swing.JLabel();
        jTxFdUnidade = new javax.swing.JTextField();
        jBtCalcularQuantidade = new javax.swing.JButton();
        jPnlControle = new javax.swing.JPanel();
        jBtConfirmar = new javax.swing.JButton();
        jBtFinalizar = new javax.swing.JButton();
        jPnlInferior = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                formComponentResized(evt);
            }
        });

        jPnlSuperior.setBorder(new javax.swing.border.MatteBorder(null));

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("SISTEMA DE ORÇAMENTOS PARA SERVIÇOS GRAFICOS");
        jLabel1.setMinimumSize(new java.awt.Dimension(0, 14));

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Inclusão de Serviços no Orçamento");
        jLabel2.setMinimumSize(new java.awt.Dimension(0, 14));

        javax.swing.GroupLayout jPnlSuperiorLayout = new javax.swing.GroupLayout(jPnlSuperior);
        jPnlSuperior.setLayout(jPnlSuperiorLayout);
        jPnlSuperiorLayout.setHorizontalGroup(
            jPnlSuperiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 836, Short.MAX_VALUE)
            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 836, Short.MAX_VALUE)
        );
        jPnlSuperiorLayout.setVerticalGroup(
            jPnlSuperiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlSuperiorLayout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPnlCentral.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPnlCentral.setMinimumSize(new java.awt.Dimension(100, 0));

        jPnlConteudo.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel5.setText("Número:");

        jTxFdidOrcamento.setEnabled(false);

        jLabel6.setText("Cliente:");

        jTxFdNomCli.setEnabled(false);

        jLabel7.setText("Vendedor:");

        jTxFdNomVen.setEnabled(false);

        jLabel8.setText("Data de Solicitação:");

        try {
            jTxFdDataSolicitacao.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jTxFdDataSolicitacao.setEnabled(false);

        jLabel9.setText("Data de Emissão:");

        try {
            jTxFdDataEmissao.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jTxFdDataEmissao.setEnabled(false);

        jLabel10.setText("Data de Encerramento:");

        try {
            jTxFdDataEncerramento.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jTxFdDataEncerramento.setEnabled(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Serviço", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N

        jPanel2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel11.setText("Item de Serviço:");

        jTxFdidItemOrcamento.setEnabled(false);

        jLabel12.setText("Descrição:");

        jTxFdDescricao.setEnabled(false);

        jLabel13.setText("Quantidade:");

        jLabel14.setText("Comprimento:");

        jLabel15.setText("Largura:");

        jLabel16.setText("Prazo de Entrega:");

        jLabel17.setText("Dt. Aprovação:");

        jLabel18.setText("Dt. Cancelamento:");

        jTxFdComprimento.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0"))));
        jTxFdComprimento.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTxFdComprimento.setEnabled(false);

        jTxFdLargura.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0"))));
        jTxFdLargura.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTxFdLargura.setEnabled(false);

        jTxFdQuantidade.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0"))));
        jTxFdQuantidade.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTxFdQuantidade.setEnabled(false);

        try {
            jTxFdPrazoEntrega.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jTxFdPrazoEntrega.setEnabled(false);

        try {
            jTxFdDataAprovacao.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jTxFdDataAprovacao.setEnabled(false);

        try {
            jTxFdDataCancelamento.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jTxFdDataCancelamento.setEnabled(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdComprimento, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdLargura, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdPrazoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdDataAprovacao, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel18))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdidItemOrcamento, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel13)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTxFdQuantidade, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTxFdDataCancelamento, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jTxFdidItemOrcamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(jTxFdDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTxFdQuantidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jTxFdComprimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18)
                    .addComponent(jTxFdDataCancelamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTxFdDataAprovacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17)
                    .addComponent(jTxFdPrazoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16)
                    .addComponent(jTxFdLargura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15))
                .addContainerGap(8, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Composição do Serviço", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N

        jLabel19.setText("Item:");

        jTxFdId.setEnabled(false);

        jLabel20.setText("Material");

        jTxFdMaterial.setEnabled(false);

        jLabel21.setText("Tipo:");

        jTxFdTipo.setEnabled(false);

        jLabel22.setText("Valor:");

        lbPorcentagemAplicacao.setText("Porcentagem da Área de Aplicação:");

        lbNumeroAplicacoes.setText("Número de Aplicações / Cores:");

        jLabel25.setText("Quantidade:");

        jLabel26.setText("Observações:");

        jTxFdObservacoes.setColumns(20);
        jTxFdObservacoes.setRows(5);
        jScrollPane1.setViewportView(jTxFdObservacoes);

        jBtPesquisaCliente.setText("Pesquisar");
        jBtPesquisaCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtPesquisaClienteActionPerformed(evt);
            }
        });

        jTxFdQuantidadeMaterial.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.0000"))));
        jTxFdQuantidadeMaterial.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        jTxFdPorcentagemAplicacao.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.00"))));
        jTxFdPorcentagemAplicacao.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        try {
            jTxFdNumeroAplicacoes.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("#")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jTxFdNumeroAplicacoes.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        jTxFdCusto.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.00"))));
        jTxFdCusto.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        jLabel23.setText("Und.:");

        jTxFdUnidade.setEnabled(false);

        jBtCalcularQuantidade.setText("Calcular Quantidade");
        jBtCalcularQuantidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtCalcularQuantidadeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                                .addComponent(lbPorcentagemAplicacao)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTxFdPorcentagemAplicacao, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lbNumeroAplicacoes)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTxFdNumeroAplicacoes, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel25)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTxFdQuantidadeMaterial, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel19)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTxFdId, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel20)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTxFdMaterial, javax.swing.GroupLayout.PREFERRED_SIZE, 354, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel21)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTxFdTipo, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel23)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTxFdUnidade, javax.swing.GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jBtPesquisaCliente))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel22)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jTxFdCusto, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel26)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 596, Short.MAX_VALUE)
                        .addComponent(jBtCalcularQuantidade))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 792, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel19)
                        .addComponent(jTxFdId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel20)
                        .addComponent(jTxFdMaterial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel21)
                        .addComponent(jTxFdTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel23)
                        .addComponent(jTxFdUnidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jBtPesquisaCliente))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbPorcentagemAplicacao)
                    .addComponent(jTxFdPorcentagemAplicacao, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbNumeroAplicacoes)
                    .addComponent(jTxFdNumeroAplicacoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25)
                    .addComponent(jTxFdQuantidadeMaterial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTxFdCusto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jBtCalcularQuantidade)
                    .addComponent(jLabel26))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout jPnlConteudoLayout = new javax.swing.GroupLayout(jPnlConteudo);
        jPnlConteudo.setLayout(jPnlConteudoLayout);
        jPnlConteudoLayout.setHorizontalGroup(
            jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlConteudoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPnlConteudoLayout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdidOrcamento, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTxFdNomCli, javax.swing.GroupLayout.DEFAULT_SIZE, 636, Short.MAX_VALUE))
                    .addGroup(jPnlConteudoLayout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdNomVen, javax.swing.GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdDataSolicitacao, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPnlConteudoLayout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdDataEmissao, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdDataEncerramento, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPnlConteudoLayout.setVerticalGroup(
            jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlConteudoLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTxFdidOrcamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jTxFdNomCli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTxFdNomVen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTxFdDataSolicitacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTxFdDataEmissao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTxFdDataEncerramento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(90, 90, 90))
        );

        jPnlControle.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jBtConfirmar.setText("Confirmar");
        jBtConfirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtConfirmarActionPerformed(evt);
            }
        });

        jBtFinalizar.setText("Finalizar");
        jBtFinalizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtFinalizarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPnlControleLayout = new javax.swing.GroupLayout(jPnlControle);
        jPnlControle.setLayout(jPnlControleLayout);
        jPnlControleLayout.setHorizontalGroup(
            jPnlControleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPnlControleLayout.createSequentialGroup()
                .addContainerGap(632, Short.MAX_VALUE)
                .addComponent(jBtConfirmar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBtFinalizar)
                .addGap(20, 20, 20))
        );
        jPnlControleLayout.setVerticalGroup(
            jPnlControleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlControleLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPnlControleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBtFinalizar)
                    .addComponent(jBtConfirmar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPnlCentralLayout = new javax.swing.GroupLayout(jPnlCentral);
        jPnlCentral.setLayout(jPnlCentralLayout);
        jPnlCentralLayout.setHorizontalGroup(
            jPnlCentralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPnlCentralLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPnlControle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(jPnlConteudo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPnlCentralLayout.setVerticalGroup(
            jPnlCentralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPnlCentralLayout.createSequentialGroup()
                .addComponent(jPnlConteudo, javax.swing.GroupLayout.PREFERRED_SIZE, 433, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                .addComponent(jPnlControle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPnlInferior.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel3.setText("Gráfica Modêlo");

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel4.setText("Grupo de Estudo PMA Anhanguera");

        javax.swing.GroupLayout jPnlInferiorLayout = new javax.swing.GroupLayout(jPnlInferior);
        jPnlInferior.setLayout(jPnlInferiorLayout);
        jPnlInferiorLayout.setHorizontalGroup(
            jPnlInferiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPnlInferiorLayout.createSequentialGroup()
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 518, Short.MAX_VALUE)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPnlInferiorLayout.setVerticalGroup(
            jPnlInferiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlInferiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel3))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPnlSuperior, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPnlInferior, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPnlCentral, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPnlSuperior, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPnlCentral, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPnlInferior, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
        // TODO add your handling code here:
        int dif = this.getHeight()-jPnlSuperior.getHeight()-jPnlCentral.getHeight()-jPnlInferior.getHeight()-6;
        jPnlCentral.setSize(this.getWidth(),this.getHeight()-jPnlSuperior.getHeight()-jPnlInferior.getHeight()-dif);
        jPnlConteudo.setSize(jPnlCentral.getWidth(),jPnlCentral.getHeight()-jPnlControle.getHeight());
        jPnlControle.setSize(jPnlCentral.getWidth(), jPnlControle.getHeight());
        jPnlControle.setLocation(0, jPnlConteudo.getHeight());
    }//GEN-LAST:event_formComponentResized

    private void jBtPesquisaClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtPesquisaClienteActionPerformed
        // TODO add your handling code here:
       PesquisaMaterial pesquisaMaterial = new PesquisaMaterial(new javax.swing.JFrame(), true);
//       cliente = new Cliente();
       pesquisaMaterial.setMaterial(material);
       pesquisaMaterial.setOpcao(0);
       material = pesquisaMaterial.getMaterial();
       pesquisaMaterial.dispose();
       if (material!=null){
          jTxFdMaterial.setText(material.getDescricao());
          jTxFdTipo.setText(material.getTipo());
          jTxFdUnidade.setText(material.getUnidade().getDescricao());
          if (material.getCusto()==null){
              jTxFdCusto.setText("");
          } else {
              jTxFdCusto.setText(material.getCusto().toString());
          }
          if (material.getTipo().equals("aplicacao")){
             lbPorcentagemAplicacao.setEnabled(true);
             jTxFdPorcentagemAplicacao.setEnabled(true);
             lbNumeroAplicacoes.setEnabled(true);
             jTxFdNumeroAplicacoes.setEnabled(true);
             jBtCalcularQuantidade.setEnabled(true);
          } else {
              if (material.getTipo().equals("plano")){
                 jBtCalcularQuantidade.setEnabled(true);
              } else {
                 jBtCalcularQuantidade.setEnabled(false);
              }
             lbPorcentagemAplicacao.setEnabled(false);
             jTxFdPorcentagemAplicacao.setEnabled(false);
             lbNumeroAplicacoes.setEnabled(false);
             jTxFdNumeroAplicacoes.setEnabled(false);
          }
       }
    }//GEN-LAST:event_jBtPesquisaClienteActionPerformed
    private void jBtFinalizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtFinalizarActionPerformed
        // TODO add your handling code here:
        boolean alterado =false;
        if (!servicoItemOrcamento.getNumeroAplicacoesToString().equals(jTxFdNumeroAplicacoes.getText()))
            alterado=true;
        if (servicoItemOrcamento.getMaterial()!=null){
           if (!servicoItemOrcamento.getMaterial().getDescricao().equals(jTxFdMaterial.getText())){
               alterado=true;
           }
        } else {
            if (!jTxFdMaterial.getText().equals("")) alterado = true;
        }
        if (servicoItemOrcamento.getValorUnitario()!=null){
           if (!servicoItemOrcamento.getValorUnitarioForm().equals(jTxFdCusto.getText())){
               alterado=true;
           }
        } else {
            if (!jTxFdCusto.getText().equals("")) alterado = true;
        }
        if (servicoItemOrcamento.getPorcentagemAplicacao()!=null){
            if (!servicoItemOrcamento.getPorcentagemAplicacao().toString().replace('.', ',').equals(jTxFdPorcentagemAplicacao.getText())){

//            if (!servicoItemOrcamento.getPorcentagemAplicacao().toString().equals(jTxFdPorcentagemAplicacao.getText())){
                alterado=true;
            }
        } else {
          if (!jTxFdPorcentagemAplicacao.getText().equals("")) alterado = true;
        }
        if (servicoItemOrcamento.getQuantidade()!=null){
            if (!servicoItemOrcamento.getQuantidadeForm().equals(jTxFdQuantidadeMaterial.getText())){
                alterado=true;
            }
        } else {
          if (!jTxFdQuantidadeMaterial.getText().equals("")) alterado = true;
        }
        if (servicoItemOrcamento.getObservacoes()!=null){
            if (!servicoItemOrcamento.getObservacoes().equals(jTxFdObservacoes.getText())){
                alterado=true;
            }
        } else {
          if (!jTxFdObservacoes.getText().equals("")) alterado = true;
        }
        if (alterado){
            if (javax.swing.JOptionPane.showConfirmDialog(null,
                    "Modificações foram feitas, deseja realmente finalizar sem salvar ?",
                    "Finalizar", javax.swing.JOptionPane.YES_NO_OPTION)==0){
               this.setVisible(false);
            }
        } else this.setVisible(false);
    }//GEN-LAST:event_jBtFinalizarActionPerformed

    private void jBtConfirmarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtConfirmarActionPerformed
        // TODO add your handling code here:
        String mensagem="";
        boolean erros = false;
        BigDecimal paBd=null;
        BigDecimal qtBd=null;
        BigDecimal vuBd=null;

        double vuDb=0;
        if (material==null){
            mensagem = mensagem + "\nInforme o Material";
            erros=true;
        } else {
          if (!material.getTipo().equals("aplicacao")){
             jTxFdNumeroAplicacoes.setText("1");
             jTxFdPorcentagemAplicacao.setText("1");
          }
        }
        if (jTxFdNumeroAplicacoes.getText().equals("")){
            mensagem = mensagem + "\nInforme o Número de aplicações";
            erros=true;
        } else {
            int na = Integer.parseInt(jTxFdNumeroAplicacoes.getText());
            if (na <1 || na > 9){
                mensagem = mensagem + "\nNúmero de aplicações deve ser de 1 a 9";
                erros=true;
            }
        }
        if (jTxFdCusto.getText().equals("")){
            mensagem = mensagem + "\nInforme o Valor";
            erros=true;
        } else {
            String vu = this.jTxFdCusto.getText();
            vu=Menu.removeChar(vu, '.');
            vu=vu.replace(',', '.');
            vuBd = new BigDecimal(vu);
            BigDecimal min = new BigDecimal("0");
            BigDecimal max = new BigDecimal("99999999999.99");
            if (vuBd.compareTo(min)<=0||vuBd.compareTo(max)>0){
                mensagem = mensagem + "\nValor deve ser maior que zero e menor que 99.999.999.999,99";
                erros=true;
            }
        }
        if (jTxFdPorcentagemAplicacao.getText().equals("")){
            mensagem = mensagem + "\nInforme a Porcentagem da aplicação";
            erros=true;
        } else {
            String pa = this.jTxFdPorcentagemAplicacao.getText();
            pa=Menu.removeChar(pa, '.');
            pa=pa.replace(',', '.');
            paBd= new BigDecimal(pa);
            BigDecimal min = new BigDecimal("0");
            BigDecimal max = new BigDecimal("99999999999.99");
            if (paBd.compareTo(min)<=0 || paBd.compareTo(max)>0){
                mensagem = mensagem + "\nPorcentagem da aplicação deve ser um valor de 0,01 a 1";
                erros=true;
            }
        }
        if (jTxFdQuantidadeMaterial.getText().equals("")){
            mensagem = mensagem + "\nInforme a Quantidade do Material";
            erros=true;
        } else {
            String qt = this.jTxFdQuantidadeMaterial.getText();
            qt=Menu.removeChar(qt, '.');
            qt=qt.replace(',', '.');
            qtBd= new BigDecimal(qt);
            BigDecimal inf = new BigDecimal("0");
            BigDecimal max = new BigDecimal("99999999999.99");
            if (qtBd.compareTo(inf)<=0||qtBd.compareTo(max)>0){
                mensagem = mensagem + "\nQuantidade do Material deve ser maior que zero e menor 99.999.999.999,99";
                erros=true;
            }
        }
        if (!erros){
            servicoItemOrcamento.setMaterial(material);
            byte na = (byte) Integer.parseInt(jTxFdNumeroAplicacoes.getText());
            servicoItemOrcamento.setNumeroAplicacoes(na);
            servicoItemOrcamento.setObservacoes(jTxFdObservacoes.getText());
            servicoItemOrcamento.setPorcentagemAplicacao(paBd);
            servicoItemOrcamento.setQuantidade(qtBd);
            servicoItemOrcamento.setValorUnitario(vuBd);
            if (this.opcao == Menu.OP_PESQ_INC){
                incluiu=true;
            } else alterou=true;
            this.setVisible(false);
        } else {
           javax.swing.JOptionPane.showMessageDialog(null,
                   "Ocorreram os seguintes erros ao serem confirmados os dados\n"+
                   mensagem+"\n"
                   + "Corrija as infromações listadas e tente confirmar novamente ",
                   "Acesso ao Banco de Dados", javax.swing.JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_jBtConfirmarActionPerformed

    private void jBtCalcularQuantidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtCalcularQuantidadeActionPerformed
        // TODO add your handling code here:
        if (material!=null){
            if (material.getTipo().equals("aplicacao")){
                BigDecimal area = new BigDecimal(servicoItemOrcamento.getItemOrcamento().getLarguraToString());
                BigDecimal comprimento = new BigDecimal(servicoItemOrcamento.getItemOrcamento().getComprimentoToString());
                BigDecimal quantidadeItem = new BigDecimal(servicoItemOrcamento.getItemOrcamento().getQuantidade().toString());
                BigDecimal rendimento = new BigDecimal(material.getRendimento().toString());
                BigDecimal areaMetro = new BigDecimal("1000000");
                BigDecimal rendimentoAux = new BigDecimal("100");
                String paStr = jTxFdPorcentagemAplicacao.getText();
                paStr=Menu.removeChar(paStr, '.');
                paStr=paStr.replace(',', '.');
                BigDecimal pA = new BigDecimal(paStr);
                String naStr = jTxFdNumeroAplicacoes.getText();
                naStr=Menu.removeChar(naStr, '.');
                naStr=paStr.replace(',', '.');
                BigDecimal nA = new BigDecimal(naStr);
                BigDecimal aux = new BigDecimal("00000");
                BigDecimal aux1 = new BigDecimal("00000");
                area = area.multiply(comprimento);
                area = area.divide(areaMetro);
                area = area.multiply(quantidadeItem);
                aux=rendimento.divide(rendimentoAux);
                aux1=pA.divide(aux);
                aux=aux1.multiply(area);
                aux1=aux.multiply(nA);
                String auxStr=aux1.toString().replace('.', ',');
                jTxFdQuantidadeMaterial.setText(auxStr);
            } else if (material.getTipo().equals("aplicacao")){
                // incluir rotina para ler arquivo corte certo
            }
        }
    }//GEN-LAST:event_jBtCalcularQuantidadeActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Principal dialog = new Principal(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtCalcularQuantidade;
    private javax.swing.JButton jBtConfirmar;
    private javax.swing.JButton jBtFinalizar;
    private javax.swing.JButton jBtPesquisaCliente;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPnlCentral;
    private javax.swing.JPanel jPnlConteudo;
    private javax.swing.JPanel jPnlControle;
    private javax.swing.JPanel jPnlInferior;
    private javax.swing.JPanel jPnlSuperior;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JFormattedTextField jTxFdComprimento;
    private javax.swing.JFormattedTextField jTxFdCusto;
    private javax.swing.JFormattedTextField jTxFdDataAprovacao;
    private javax.swing.JFormattedTextField jTxFdDataCancelamento;
    private javax.swing.JFormattedTextField jTxFdDataEmissao;
    private javax.swing.JFormattedTextField jTxFdDataEncerramento;
    private javax.swing.JFormattedTextField jTxFdDataSolicitacao;
    private javax.swing.JTextField jTxFdDescricao;
    private javax.swing.JTextField jTxFdId;
    private javax.swing.JFormattedTextField jTxFdLargura;
    private javax.swing.JTextField jTxFdMaterial;
    private javax.swing.JTextField jTxFdNomCli;
    private javax.swing.JTextField jTxFdNomVen;
    private javax.swing.JFormattedTextField jTxFdNumeroAplicacoes;
    private javax.swing.JTextArea jTxFdObservacoes;
    private javax.swing.JFormattedTextField jTxFdPorcentagemAplicacao;
    private javax.swing.JFormattedTextField jTxFdPrazoEntrega;
    private javax.swing.JFormattedTextField jTxFdQuantidade;
    private javax.swing.JFormattedTextField jTxFdQuantidadeMaterial;
    private javax.swing.JTextField jTxFdTipo;
    private javax.swing.JTextField jTxFdUnidade;
    private javax.swing.JTextField jTxFdidItemOrcamento;
    private javax.swing.JTextField jTxFdidOrcamento;
    private javax.swing.JLabel lbNumeroAplicacoes;
    private javax.swing.JLabel lbPorcentagemAplicacao;
    // End of variables declaration//GEN-END:variables
    
}
